package com.yst.gateway.monitor.services.impl;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.yst.gateway.monitor.services.QzDownloadService;

@Service
@Scope("prototype")
public class QzDownloadServiceImpl implements QzDownloadService{

	@Override
	public void getFileContent(OutputStream os, String filePathName) {
		
		InputStream is = null;
	 
		try {
		 
			is = new FileInputStream(new File(filePathName));            
            byte[] b = new byte[2048];
            int length;
            while ((length = is.read(b)) > 0) {
                os.write(b, 0, length);
                os.flush();
            } 
        
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        
	}

}
